package com.zzy.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzy.system.domain.PurchaseOrderDetail;
import com.zzy.system.domain.PurchaseOrderDetailItem;
import com.zzy.system.domain.SaleOrderDetail;
import com.zzy.system.mapper.PurchaseOrderDetailMapper;
import com.zzy.system.mapper.SaleOrderDetailMapper;
import com.zzy.system.service.IPurchaseOrderDetailService;
import com.zzy.system.service.ISaleOrderDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SaleOrderDetailServiceImpl extends ServiceImpl<SaleOrderDetailMapper, SaleOrderDetail> implements ISaleOrderDetailService {
    private static final Logger log = LoggerFactory.getLogger(SaleOrderDetailServiceImpl.class);

    @Override
    public void saveOrderDetails(List<SaleOrderDetail> saleOrderDetailList) {
        if(!saleOrderDetailList.isEmpty()){
            QueryWrapper<SaleOrderDetail> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("order_id", saleOrderDetailList.get(0).getOrderId());
            baseMapper.delete(queryWrapper);
            this.saveBatch(saleOrderDetailList);
        }
    }
}